//
//  StepperBoot.swift
//  SwiftUIWidgetDemo
//
//  Created by alanzhangg on 2023/7/17.
//

import SwiftUI

struct StepperBoot: View {
    
    @State var stepperValue: Int = 10
    @State var withIncrement: CGFloat = 0
    var body: some View {
        VStack {
            Stepper("Stepper \(stepperValue)", value: $stepperValue)
                .padding()
            
            RoundedRectangle(cornerRadius: 25.0)
                .frame(width: withIncrement, height: 100)
            
            Stepper("Stepper 2") {
                //increment
                incrementWidth(amount: 10)
            } onDecrement: {
                //decrement
                incrementWidth(amount: -10)
            }
            .padding()
        }
    }
    func incrementWidth(amount: CGFloat){
        withAnimation {
            withIncrement += amount
        }
    }
}

#Preview {
    StepperBoot()
}
